package com.lishuang.basic.service.impl;

import com.lishuang.basic.service.IBaiduAiAuditService;
import com.lishuang.basic.util.BaiduAuditUtils;
import org.springframework.stereotype.Service;

@Service
public class BaiduAiAuditServiceImpl implements IBaiduAiAuditService {

    @Override
    public Boolean textAudit(String auditText) {
        //@TODO - 自主研发 - 工具类BaiduAuditUtils
        if (auditText != null && auditText.length() > 0) {
            Boolean boo = BaiduAuditUtils.TextCensor(auditText);
            return boo;
        }
        return true;
    }
    /*
     *  注意:resources是这样的格式：
     *  /group1/M00/00/02/CgAIC2KevEeAX2T4AAEUusLjqqk161.png,/group1/M00/00/02/CgAIC2KevEeAX2T4AAEUusLjqqk162.png
     *  需要判断是否为空，只有一张怎么处理，有多张怎么处理
     *  需要统一加前缀：http://123.207.27.208
     */
    @Override
    public Boolean imageAudit(String resources) {
        //@TODO - 自主研发 - 工具类BaiduAuditUtils

        if (resources != null && resources.length() > 0) {

            String prefix = "http://123.207.27.208";
            String[] res = resources.split(",");
            for (String re : res) {
                Boolean boo = BaiduAuditUtils.ImgCensor(prefix + re);
                if (!boo) {
                    return false;
                }
            }
        }
        return true;
    }

   /* public static void main(String[] args) {
        String a = "/group1/M00/00/02/CgAIC2KevEeAX2T4AAEUusLjqqk161.png,/group1/M00/00/02/CgAIC2KevEeAX2T4AAEUusLjqqk162.png";
        String[] strings = a.split(",");
        System.out.println(Arrays.toString(strings));
    }*/
}